---
title: 'Cypress API: Table of Contents'
description: 'Cypress commands, assertions, actions, and other commands to help write tests.'
sidebar_label: 'Table of Contents'
sidebar_position: 10
---

<ProductHeading product="app" />

# Table of Contents

## Commands

Cypress commands don't do anything at the moment they are invoked, but rather
enqueue themselves to be run later. Commands can be chained together
because Cypress manages a Promise chain on your behalf, with each command
yielding a 'subject' to the next command, until the chain ends or an error is
encountered.

Learn more about how commands chain together in the
[Introduction to Chains of Commands](/app/core-concepts/introduction-to-cypress#Chains-of-Commands).

Cypress commands can be classified one of the following

- `query` - commands that read the state of your application
- `assertion` - command which assert on a given state
- `action` - interact with your application as a user would
- `other` - any other command that is useful for writing tests

The differences between queries and other commands are outline in the
[Retry-ability Guide](/app/core-concepts/retry-ability).

### Queries

Queries are Cypress commands that read the state of your application. They
return a subject for further commands to act or assert on, and retry as needed
to make sure the DOM element or other data they yield is always up to date.

| Command                                         | Usage                                                                                                      |
| ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| [`.as()`](/api/commands/as)                     | Assign an alias for later use. Reference the alias later within a `cy.get()` query or `cy.wait()` command. |
| [`.children()`](/api/commands/children)         | Get the children of each element within a set of DOM elements.                                             |
| [`.closest()`](/api/commands/closest)           | Get the first ancestral element that matches a selector.                                                   |
| [`.contains()`](/api/commands/contains)         | Select a DOM element by text content.                                                                      |
| [`.document()`](/api/commands/document)         | Get the `window.document` of the active page.                                                              |
| [`.eq()`](/api/commands/eq)                     | Select a DOM element by index from a collection.                                                           |
| [`.filter()`](/api/commands/filter)             | Filter elements with a selector.                                                                           |
| [`.find()`](/api/commands/find)                 | Find descendent elements with a selector.                                                                  |
| [`.first()`](/api/commands/first)               | Select the first item in a collection.                                                                     |
| [`.focused()`](/api/commands/focused)           | Get the DOM element that is currently focused.                                                             |
| [`.get()`](/api/commands/get)                   | Find DOM elements by selector, or read an alias previously created with the `.as()` command.               |
| [`.hash()`](/api/commands/hash)                 | Get the URL hash of the active page.                                                                       |
| [`.invoke()`](/api/commands/invoke)             | Invoke a function on the previously yielded subject.                                                       |
| [`.its()`](/api/commands/its)                   | Get a property's value on the previously yielded subject.                                                  |
| [`.last()`](/api/commands/last)                 | Select the last item in a collection.                                                                      |
| [`.location()`](/api/commands/location)         | Get the `window.location` object of the active page.                                                       |
| [`.next()`](/api/commands/next)                 | Get the next sibling element.                                                                              |
| [`.nextAll()`](/api/commands/nextall)           | Get all following sibling elements.                                                                        |
| [`.nextUntil()`](/api/commands/nextuntil)       | Get all following sibling elements until reaching a selector.                                              |
| [`.not()`](/api/commands/not)                   | Filter selected elements with a selector.                                                                  |
| [`.parent()`](/api/commands/parent)             | Get the parent of a DOM element.                                                                           |
| [`.parents()`](/api/commands/parents)           | Get all parent elements of a DOM element.                                                                  |
| [`.parentsUntil()`](/api/commands/parentsuntil) | Get all parent elements up to a selector.                                                                  |
| [`.prev()`](/api/commands/prev)                 | Get the previous sibling element.                                                                          |
| [`.prevAll()`](/api/commands/prevall)           | Get all previous sibling elements.                                                                         |
| [`.prevUntil()`](/api/commands/prevuntil)       | Get all following previous sibling elements until reaching a selector.                                     |
| [`.root()`](/api/commands/root)                 | Get the root DOM element.                                                                                  |
| [`.shadow()`](/api/commands/shadow)             | Traverse into the shadow DOM of an element.                                                                |
| [`.siblings()`](/api/commands/siblings)         | Get all sibling elements.                                                                                  |
| [`.title()`](/api/commands/title)               | Get the `document.title` property of the active page.                                                      |
| [`.url()`](/api/commands/url)                   | Get the URL of the active page.                                                                            |
| [`.window()`](/api/commands/window)             | Get the `window` object of the active page.                                                                |

### Assertions

Assertions are Cypress commands that assert on the state of your application.
They pause your test until the given condition is met, or until they time out.
Learn more about Cypress assertions in the
[Introduction to Assertions](/app/core-concepts/introduction-to-cypress#Assertions)
and the [Assertions Reference](/app/references/assertions).

| Command                             | Usage                                                                                                      |
| ----------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| [`.and()`](/api/commands/and)       | Alias for `.should(). Assert on the state of your application`.                                            |
| [`.should()`](/api/commands/should) | Assert on the state of your application. Assertions are automatically retried until they pass or time out. |

### Actions

Actions are Cypress commands that interact with your application as a user
would. They wait for elements to be actionable before interacting with the page.

Learn more about action commands in our
[Actionability Guide](/app/core-concepts/interacting-with-elements).

| Command                                             | Usage                                                                                    |
| --------------------------------------------------- | ---------------------------------------------------------------------------------------- |
| [`.check()`](/api/commands/check)                   | Check checkbox or radio elements.                                                        |
| [`.clear()`](/api/commands/clear)                   | Clear the value of an input or textarea.                                                 |
| [`.click()`](/api/commands/click)                   | Click a DOM element.                                                                     |
| [`.dblclick()`](/api/commands/dblclick)             | Double-click a DOM element.                                                              |
| [`.rightclick()`](/api/commands/rightclick)         | Right click a DOM element.                                                               |
| [`.scrollIntoView()`](/api/commands/scrollintoview) | Scroll an element into view.                                                             |
| [`.scrollTo()`](/api/commands/scrollto)             | Scroll to a specific position.                                                           |
| [`.select()`](/api/commands/select)                 | Select an `<option>` within a `<select>`.                                                |
| [`.selectFile()`](/api/commands/selectfile)         | Selects a file in an HTML5 input element, or simulates dragging a file into the browser. |
| [`.trigger()`](/api/commands/trigger)               | Trigger an event on a DOM element.                                                       |
| [`.type()`](/api/commands/type)                     | Type into a DOM element.                                                                 |
| [`.uncheck()`](/api/commands/uncheck)               | Uncheck checkbox(es).                                                                    |

### Other Commands

Cypress has a variety of additional commands to help write tests.

| Command                                                             | Usage                                                                                                                                                                           |
| ------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`.blur()`](/api/commands/blur)                                     | Blur a focused element. Blur is not an action command, because users cannot directly unfocus an element, only focus a new one, but `.blur()` can be used as a testing shortcut. |
| [`.clearAllCookies()`](/api/commands/clearallcookies)               | Clear all browser cookies.                                                                                                                                                      |
| [`.clearAllLocalStorage()`](/api/commands/clearalllocalstorage)     | Clear `localStorage` data for all origins with which the test has interacted.                                                                                                   |
| [`.clearAllSessionStorage()`](/api/commands/clearallsessionstorage) | Clear `sessionStorage` data for all origins with which the test has interacted.                                                                                                 |
| [`.clearCookie()`](/api/commands/clearcookie)                       | Clear a specific browser cookie.                                                                                                                                                |
| [`.clearCookies()`](/api/commands/clearcookies)                     | Clear browser cookies for a domain.                                                                                                                                             |
| [`.clearLocalStorage()`](/api/commands/clearlocalstorage)           | Clear data in `localStorage` for current domain and subdomain.                                                                                                                  |
| [`.clock()`](/api/commands/clock)                                   | Override the browser's built-in time objects (`Date`, `setTimeout` and similar), allowing them to be controlled via `cy.tick()`.                                                |
| [`.debug()`](/api/commands/debug)                                   | Set a `debugger` statement and log what the previous command yields.                                                                                                            |
| [`.each()`](/api/commands/each)                                     | Invoke a callback on each item in an array.                                                                                                                                     |
| [`.end()`](/api/commands/end)                                       | Explicitly end a chain of Cypress commands.                                                                                                                                     |
| [`.exec()`](/api/commands/exec)                                     | Execute a system command.                                                                                                                                                       |
| [`.fixture()`](/api/commands/fixture)                               | Load a fixed set of data from disk.                                                                                                                                             |
| [`.focus()`](/api/commands/focus)                                   | Focus on a DOM element. Focus is not an action command, because users cannot directly focus an element, but `.focus()` can be used as a testing shortcut.                       |
| [`.getAllCookies()`](/api/commands/getallcookies)                   | Get all browser cookies.                                                                                                                                                        |
| [`.getAllLocalStorage()`](/api/commands/getalllocalstorage)         | Get `localStorage` data for all origins with which the test has interacted.                                                                                                     |
| [`.getAllSessionStorage()`](/api/commands/getallsessionstorage)     | Get `sessionStorage` data for all origins with which the test has interacted.                                                                                                   |
| [`.getCookie()`](/api/commands/getcookie)                           | Get a browser cookie by its name.                                                                                                                                               |
| [`.getCookies()`](/api/commands/getcookies)                         | Get browser cookies for the current domain or a specified domain.                                                                                                               |
| [`.go()`](/api/commands/go)                                         | Navigate back or forward using the browser's history.                                                                                                                           |
| [`.hover()`](/api/commands/hover)                                   | Cypress does not have a cy.hover() command. See [Issue #10](https://github.com/cypress-io/cypress/issues/10).                                                                   |
| [`.intercept()`](/api/commands/intercept)                           | Spy and stub network requests and responses.                                                                                                                                    |
| [`.log()`](/api/commands/log)                                       | Print a message to the Cypress Command Log.                                                                                                                                     |
| [`.mount()`](/api/commands/mount)                                   | Mount a component for Cypress Component Testing.                                                                                                                                |
| [`.origin()`](/api/commands/origin)                                 | Visit multiple domains of different origin in a single test.                                                                                                                    |
| [`.pause()`](/api/commands/pause)                                   | Pause test execution, allowing interaction with the application under test before resuming.                                                                                     |
| [`.press()`](/api/commands/press)                                   | Trigger native key events in your application to simulate real user keyboard interactions.                                                                                      |
| [`.prompt()`](/api/commands/prompt)                                 | Use natural language to generate Cypress tests with AI.                                                                                                                         |
| [`.readFile()`](/api/commands/readfile)                             | Read a file from disk.                                                                                                                                                          |
| [`.reload()`](/api/commands/reload)                                 | Reload the page.                                                                                                                                                                |
| [`.request()`](/api/commands/request)                               | Make an HTTP request.                                                                                                                                                           |
| [`.screenshot()`](/api/commands/screenshot)                         | Take a screenshot of the application under test.                                                                                                                                |
| [`.session()`](/api/commands/session)                               | Cache and restore cookies, localStorage, and sessionStorage (i.e. session data) in order to recreate a consistent browser context between tests.                                |
| [`.setCookie()`](/api/commands/setcookie)                           | Set a browser cookie.                                                                                                                                                           |
| [`.spread()`](/api/commands/spread)                                 | Invoke a callback function with multiple arguments. Similar to `.then()`.                                                                                                       |
| [`.spy()`](/api/commands/spy)                                       | Wrap a method in a spy in order to record calls to the function.                                                                                                                |
| [`.stub()`](/api/commands/stub)                                     | Replace a method, record its usage and control its behavior.                                                                                                                    |
| [`.submit()`](/api/commands/submit)                                 | Submit a form.                                                                                                                                                                  |
| [`.task()`](/api/commands/task)                                     | Execute code in Node via the `task` plugin event.                                                                                                                               |
| [`.then()`](/api/commands/then)                                     | Invoke a callback function with the current subject, allowing you to execute code at specific points during a Cypress test.                                                     |
| [`.tick()`](/api/commands/tick)                                     | Move time after overriding a native time functions with `cy.clock()`.                                                                                                           |
| [`.viewport()`](/api/commands/viewport)                             | Control the size and orientation of the screen for your application.                                                                                                            |
| [`.visit()`](/api/commands/visit)                                   | Visit a remote URL. Many tests begin with this command.                                                                                                                         |
| [`.wait()`](/api/commands/wait)                                     | Wait a number of milliseconds, or wait for an aliased resource to resolve.                                                                                                      |
| [`.within()`](/api/commands/within)                                 | Scopes all subsequent cy commands to within this element. Useful when working within a particular group of elements such as a `<form>`.                                         |
| [`.wrap()`](/api/commands/wrap)                                     | Yield the object passed into `.wrap()`. If the object is a promise, yield its resolved value.                                                                                   |
| [`.writeFile()`](/api/commands/writefile)                           | Write to a file with the specified contents.                                                                                                                                    |

## Cypress API

### Events

Cypress emits a series of events as it runs in your browser. These events are
useful not only to control your application's behavior, but also for debugging
purposes. Learn more about them in the
[Catalog of Events](/api/cypress-api/catalog-of-events).

### Custom Commands and Queries

Cypress exposes interfaces to write
[Custom Commands](/api/cypress-api/custom-commands) and
[Custom Queries](/api/cypress-api/custom-queries). See those pages for more
details.

The Cypress community has created a large number of

<a href="/app/plugins/plugins-list#custom-commands">Command Plugins</a> which you
can install or download.

### APIs

Cypress exposes a number of properties and methods on the global `Cypress`
object.

The _key_ difference between Cypress APIs and Cypress commands is that Cypress
APIs execute the moment they are invoked and are **not** enqueued to run at a
later time.

| Property                                                           | Usage                                                                                                                          |
| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| [`Cypress.arch`](/api/cypress-api/arch)                            | CPU architecture name of the underlying OS, as returned from Node's `os.arch()`.                                               |
| [`Cypress.browser`](/api/cypress-api/browser)                      | Information about the current browser, such as browser family and version.                                                     |
| [`Cypress.Commands`](/api/cypress-api/custom-commands)             | Create new custom commands and extend or override existing ones.                                                               |
| [`Cypress.config()`](/api/cypress-api/config)                      | Get and set Cypress configuration from inside your tests.                                                                      |
| [`Cypress.Cookies.debug()`](/api/cypress-api/cookies)              | Generate console logs whenever a cookie is modified.                                                                           |
| [`Cypress.currentRetry`](/api/cypress-api/currentretry)            | A number representing the current test retry count.                                                                            |
| [`Cypress.currentTest`](/api/cypress-api/currenttest)              | An object with information about the currently executing test.                                                                 |
| [`Cypress.log`](/api/cypress-api/cypress-log)                      | This is the internal API for controlling what gets printed to the Command Log. Useful when writing your own custom commands.   |
| [`Cypress.dom`](/api/cypress-api/dom)                              | A collection of DOM related helper methods.                                                                                    |
| [`Cypress.ElementSelector`](/api/cypress-api/element-selector-api) | Configure selector priority used by [Cypress Studio](/app/guides/cypress-studio) and [cy.prompt()](/api/commands/prompt).      |
| [`Cypress.env`](/api/cypress-api/env)                              | Get environment variables from inside your tests.                                                                              |
| [`Cypress.isBrowser()`](/api/cypress-api/isbrowser)                | Checks if the current browser matches the given name or filter.                                                                |
| [`Cypress.isCy()`](/api/cypress-api/iscy)                          | checks if a variable is a valid instance of cy or a cy chainable.                                                              |
| [`Cypress.Keyboard.defaults()`](/api/cypress-api/keyboard-api)     | Set default values for how the `.type()` command is executed.                                                                  |
| [`Cypress.platform`](/api/cypress-api/platform)                    | The underlaying OS name, as returned by Node's `os.platform()`.                                                                |
| [`Cypress.require`](/api/cypress-api/require)                      | Enables utilizing dependencies within the [cy.origin()](/api/commands/origin) callback function.                               |
| [`Cypress.Screenshot.defaults()`](/api/cypress-api/screenshot-api) | Set defaults for screenshots captured by the `.screenshot()` command and the automatic screenshots taken during test failures. |
| [`Cypress.session`](/api/cypress-api/session)                      | A collection of helper methods related to the `.session()` command.                                                            |
| [`Cypress.spec`](/api/cypress-api/spec)                            | An object with information about the currently executing spec file.                                                            |
| [`Cypress.testingType`](/api/cypress-api/testing-type)             | The current testing type, eg. `"e2e"` or `"component".                                                                         |
| [`Cypress.version`](/api/cypress-api/version)                      | The current Cypress version.                                                                                                   |

## Utilities

Cypress makes several common libraries available directly on the global
`Cypress` object.

| Utility                                         | Usage                                                                                                                                    |
| ----------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| [`Cypress.$`](/api/utilities/$)                 | Cypress automatically includes [jQuery](http://jquery.com/) and exposes it as `Cypress.$`.                                               |
| [`Cypress.Blob`](/api/utilities/blob)           | Cypress automatically includes a [Blob](https://github.com/nolanlawson/blob-util) library and exposes it as `Cypress.Blob`.              |
| [`Cypress.Buffer`](/api/utilities/buffer)       | Cypress automatically includes a [Buffer polyfill](https://github.com/feross/buffer) for the browser and exposes it as `Cypress.Buffer`. |
| [`Cypress._`](/api/utilities/_)                 | Cypress automatically includes [lodash](https://lodash.com/) and exposes it as `Cypress._`.                                              |
| [`Cypress.minimatch`](/api/utilities/minimatch) | Cypress automatically includes [minimatch](https://github.com/isaacs/minimatch) and exposes it as `Cypress.minimatch`.                   |
| [`Cypress.Promise`](/api/utilities/promise)     | Cypress automatically includes `Bluebird` and exposes it as `Cypress.Promise`.                                                           |
| [`Cypress.sinon`](/api/utilities/sinon)         | Cypress automatically includes [Sinon.JS](http://sinonjs.org/) and exposes it as `Cypress.sinon`.                                        |

## Node Events

The Node Events allow you to hook into and extend Cypress behavior. For more
details, see the [How to use a Plugin](/app/plugins/plugins-guide) and
[Node Events Overview](/api/node-events/overview).

| API                                                             | Usage                                                                                                                                                                                                                                                                    |
| --------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [After Run Event](/api/node-events/after-run-api)               | The `after:run` event fires after a run is finished. When running cypress via cypress open, the event will fire when closing a project.                                                                                                                                  |
| [After Screenshot Event](/api/node-events/after-screenshot-api) | After a screenshot is taken, you can get details about it via the `after:screenshot` plugin event.                                                                                                                                                                       |
| [After Spec Event](/api/node-events/after-spec-api)             | The `after:spec` event fires after a spec file is run. When running cypress via cypress open, the event will fire when the browser closes.                                                                                                                               |
| [Before Run Event](/api/node-events/before-run-api)             | The `before:run` event fires before a run starts. When running cypress via cypress open, the event will fire when opening a project.                                                                                                                                     |
| [Before Spec Event](/api/node-events/before-spec-api)           | The `before:spec` event fires before a spec file is run. When running cypress via cypress open, the event will fire when the browser launches.                                                                                                                           |
| [Browser Launch API](/api/node-events/browser-launch-api)       | Before Cypress launches a browser, it gives you the opportunity to modify the browser preferences, install extensions, add and remove command-line arguments, and modify other options from the [`setupNodeEvents`](/app/plugins/plugins-guide#Using-a-plugin) function. |
| [Configuration API](/api/node-events/configuration-api)         | Cypress enables you to dynamically modify configuration values and environment variables from your Cypress configuration.                                                                                                                                                |
| [Preprocessors API](/api/node-events/preprocessors-api)         | A preprocessor is the plugin responsible for preparing a support file or a test file for the browser. A preprocessor also typically watches the source files for changes, processes them again, and then notifies Cypress to re-run the tests.                           |
